<?php
require_once("dao/tournaments_dao.php");


class tournaments_controller extends abstract_controller {

	function prepare_model($request_params, Smarty $smarty_obj) { 
		
		
		//Skal tillate at en sletter en turnering.
//		if($_SESSION['admin']) {
//			$smarty_obj->assign("admin", true);
//			$delete = isset($_GET['delete']) ? htmlentities($_GET['delete']) : "";
//			
//			if(!empty($delete)) {
//				tournaments_dao::deleteTournament($delete);
//				$smarty_obj->assign("delmsg", "Turnering slettet");
//			}
//		}
		
		
		$tournaments = tournaments_dao::listOfTournaments();
		
		if(!empty($tournaments)) {
			foreach($tournaments as $tournament) {
					$new_tournaments[] = $tournament->name;
			}
		}
		
		$smarty_obj->assign("tournaments", $new_tournaments);
		
		$smarty_obj->assign("page_title", "Tour Builder");
		
		
		
		
	}
	
}
?>